<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rams_Extension_ConcurrentParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_path = null;
    protected $_hits = null;
    protected $_updated = null;
    protected $_timestamp = null;
    protected $_datetime = null;

    public function __construct($path = null, $hits = null, $updated = null) 
    {
        parent::__construct();
        $this->setPath($path);
        $this->setHits($hits);
        $this->setUpdated($updated);
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = NULL, $majorVersion = 1, $minorVersion = NULL)
    {
        $element = parent::getDOM($doc);
        if ($this->_path !== null) {
            $element->appendChild($this->_path->getDOM($element->ownerDocument));
        }
        if ($this->_hits !== null) {
            $element->appendChild($this->_hits->getDOM($element->ownerDocument));
        }
        if ($this->_updated !== null) {
            $element->appendChild($this->_updated->getDOM($element->ownerDocument));
        }
        if ($this->_timestamp != null) {
          $element->appendChild($this->_timestamp->getDOM($element->ownerDocument));
        }
        if ($this->_datetime != null) {
          $element->appendChild($this->_datetime->getDOM($element->ownerDocument));
        }
        
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'path'; 
                $path = new Rams_Extension_Path();
                $path->transferFromDOM($child);
                $this->_path = $path;
                break;
            case $this->lookupNamespace('raws') . ':' . 'hits'; 
                $hits = new Rams_Extension_Hits();
                $hits->transferFromDOM($child);
                $this->_hits = $hits;
                break;
            case $this->lookupNamespace('raws') . ':' . 'updated'; 
                $updated = new Rams_Extension_Updated();
                $updated->transferFromDOM($child);
                $this->_updated = $updated;
                break;
            case $this->lookupNamespace('raws') . ':' . 'timestamp'; 
                $timestamp = new Rams_Extension_Timestamp();
                $timestamp->transferFromDOM($child);
                $this->_timestamp = $timestamp;
                break;
            case $this->lookupNamespace('raws') . ':' . 'datetime'; 
                $datetime = new Rams_Extension_Datetime();
                $datetime->transferFromDOM($child);
                $this->_datetime = $datetime;
                break;
              
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getPath()
    {
        return $this->_path;
    }

    public function setPath($value)
    {
        $this->_path = $value;
        return $this;
    }

    public function getHits()
    {
        return $this->_hits;
    }

    public function setHits($value)
    {
        $this->_hits = $value;
        return $this;
    }

    public function getUpdated()
    {
        return $this->_updated;
    }

    public function setUpdated($value)
    {
        $this->_updated = $value;
        return $this;
    }

    public function getTimestamp()
    {
        return $this->_timestamp;
    }

    public function setTimestamp($value)
    {
        $this->_timestamp = $value;
        return $this;
    }
    
    public function getDatetime()
    {
        return $this->_datetime;
    }

    public function setDatetime($value)
    {
        $this->_datetime = $value;
        return $this;
    }

}
